package DBLayer;

import static org.junit.Assert.*;

import java.util.Calendar;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import ModelLayer.Opening;

public class DBOpeningTest {
	
	private DBOpening dbOpen;	

	@Before
	public void setUp() throws Exception {
		dbOpen = new DBOpening();
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void getOpeningByDay() {
		try
		{	
			Calendar cal = Calendar.getInstance();

			int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
			
			String day = "";
			
			switch(dayOfWeek)
			{
				case 1: day = "sunday";
				break;
				case 2: day = "monday";
				break;
				case 3: day = "tuesday";
				break;
				case 4: day = "wednesday";
				break;
				case 5: day = "thursday";
				break;
				case 6: day = "friday";
				break;
				case 7: day = "saturday";
				break;
			}
			
			Opening open = dbOpen.getOpeningByDay(day);
			
			if(open != null)
			{
				System.out.println(open.getDayOfWeek() + " Open time: " + open.getOpenTime().toString() + " Close time: " + open.getCloseTime().toString());
			}
		}
		catch(Exception err)
		{
			fail("Not yet implemented");
		}	
	}
}
